package com.xposed.aliproxy.thread;

import android.content.Context;
import android.content.Intent;

import com.xposed.aliproxy.qrcode.GlobalInstance;
import com.xposed.aliproxy.qrcode.QRCodeModel;
import com.xposed.aliproxy.socket.SocketManager;
import com.xposed.aliproxy.utils.JsonUtil;
import com.xposed.aliproxy.utils.ParamConfig;
import com.xposed.aliproxy.utils.ToastUtil;
import com.xposed.aliproxy.utils.Utils;
import com.xposed.aliproxy.utils.XposeUtil;

import org.json.JSONObject;
import de.robv.android.xposed.XposedBridge;

/* renamed from: h.e */
public class SocketReadThread extends Thread {
    /* renamed from: a */
    public boolean f1796a = false;
    /* renamed from: b */
    public boolean f1797b = false;
    /* renamed from: c */
    private Context f1798c;
    /* renamed from: d */
    private SocketManager f1799d;

    public SocketReadThread(Context context) {
        this.f1798c = context;
    }

    public void run() {
        super.run();
        this.f1797b = true;
        while (!GlobalInstance.getInstance().f1764c && !this.f1796a) {
            this.f1799d = SocketManager.m2947a(this.f1798c);
            try {
                Thread.sleep(300);
                String a = this.f1799d.mo3616a();
                if (a != null) {
                    m2964a(a);
                }
            } catch (Throwable th) {
                XposedBridge.log(th);
                SocketManager.m2950b();
            }
        }
    }

    /* renamed from: a */
    private void m2964a(String str) {
        try {
            if (!Utils.isNull(str) && !"xintiao".equals(str)) {
                JSONObject jSONObject = new JSONObject(str);
                str = JsonUtil.getString(jSONObject, "respCode");
                String a = JsonUtil.getString(jSONObject, "transType");
                String a2;
                if (Utils.isNull(str)) {
                    if ("P010".equals(a)) {
                        str = JsonUtil.getString(jSONObject, "inAccount");
                        if (ParamConfig.getInstance(this.f1798c).getString("aliAccount", "").equals(str)) {
                            a = JsonUtil.getString(jSONObject, "orderNo");
                            String a3 = JsonUtil.getString(jSONObject, "money");
                            a2 = JsonUtil.getString(jSONObject, "qrCodeRemark");
                            int parseInt = Integer.parseInt(a3);
                            if (parseInt > 0 && parseInt <= 5000000) {
                                if (a2 == null || a2.length() > 20) {
                                    a2 = XposeUtil.m2989a();
                                }
                                QRCodeModel qRCodeModel = new QRCodeModel();
                                qRCodeModel.setInAccount(str);
                                qRCodeModel.setMoney(a3);
                                qRCodeModel.setOrderNo(a);
                                qRCodeModel.setQrCodeRemark(a2);
                                GlobalInstance.getInstance().qrCodeModelArrayList.add(qRCodeModel);
                                str = Utils.formatStr2Decimal(a3);
                                Intent intent = new Intent("com.abcd.action.xposedaction.generateqrcode");
                                intent.putExtra("money", str);
                                intent.putExtra("remark", a2);
                                this.f1798c.sendBroadcast(intent);
                            } else {
                                return;
                            }
                        }
                        return;
                    }
                    return;
                }
                if ("P009".equals(a)) {
                    if ("00".equals(str)) {
                        this.f1798c.sendBroadcast(new Intent("com.abcd.xpouseali.action.aliloginsuccess"));
                    } else {
                        this.f1798c.sendBroadcast(new Intent("com.abcd.xpouseali.action.aliloginfailed"));
                    }
                }
                if (!"00".equals(str)) {
                    a2 = JsonUtil.getString(jSONObject, "respMsg");
                    Context context = this.f1798c;
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.append(str);
                    stringBuilder.append("->");
                    stringBuilder.append(a2);
                    ToastUtil.showToast(context, stringBuilder.toString());
                }
            }
        } catch (Throwable th) {
            XposedBridge.log(th);
        }
    }
}
